package net.csdn.business.kanban.feign.api;


import net.csdn.business.kanban.common.constant.ServiceNameConstants;
import net.csdn.business.kanban.common.domain.DTO.*;
import net.csdn.business.kanban.common.model.dto.UserRoleDto;
import net.csdn.business.kanban.common.model.vo.UserInfoVO;
import net.csdn.business.kanban.feign.decoder.SystemFeignErrorDecoder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.groups.Default;
import java.util.List;
import java.util.Map;

/**
 * @ClassName IssueFeignClient
 * @Description TODO
 * @Author liuzhisheng
 * @Date 2023/9/18
 **/
@FeignClient(value = ServiceNameConstants.GIT_ISSUE_SERVICE,url = "${feign.service.issue}", configuration = SystemFeignErrorDecoder.class)
public interface IssueFeignClient {

    /**
     * 批量查询某项目下的issue列表
     * @param projectId
     * @return
     */
    @GetMapping("/api/v1/issue/issueList/{projectId}")
    List<IssueVoDto> issueList(@PathVariable("projectId") Long projectId, @RequestParam("searchBy") String searchBy);

    /**
     * 获取issue明细
     * @param issuerId
     * @param uid
     * @return
     */
    @GetMapping("/api/v1/issue/issueDetail")
    IssueVoDto issueDetail(@RequestParam(value = "issuerId") String issuerId, @RequestParam(value = "uid") String uid);

    /**
     * 获取label
     * @return
     */
    @PostMapping("/api/v1/label/batch/labels")
    Map<String, LabelVo> getBatchLabels(@RequestBody List<String> labelIds);

    /**
     * 获取里程碑
     * @return
     */
    @PostMapping("/api/v1/milepost/batch/mileposts")
    Map<String, MilepostVo> getBatchMileposts(@RequestBody List<String> milepostIds);

    /**
     * 获取负责人
     * @return
     */
    @PostMapping("/api/v1/issue/batch/assignUsers")
    Map<String, UserVo> getBatchAssignUsers(@RequestBody List<String> uids);

    /**
     * 更新issue标题
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/issue/update")
    IssueVoDto updateIssueTitle(@Validated({System.class, Default.class}) @RequestBody IssueUpdateReqDto dto);

    /**
     * 更新issue负责人
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/issue/update/assign")
    IssueVoDto updateAssignUser(@Validated({System.class, Default.class}) @RequestBody IssueAssignUserRequestDto dto);

    /**
     * 批量关联label
     * @param param
     */
    @PostMapping("/api/v1/label/issue/batchLink")
    void batchLinkIssueLabels(@Validated({System.class, Default.class}) @RequestBody LabelIssueBatchLinkDto param);

    /**
     * 移除issue关联的label
     * @param uid
     * @param issueId
     * @param labelId
     */
    @DeleteMapping("/api/v1/label/issue/unlink")
    void removeIssueLabel(@RequestParam("uid") String uid, @RequestParam("issueId") String issueId, @RequestParam("labelId") String labelId,@RequestParam(value = "isSyncKanban",required = false) Boolean isSyncKanban);

    /**
     * issue关联里程碑
     * @param param
     */
    @PostMapping("/api/v1/milepost/batch/link_issue")
    void batchLinkIssueMilepost(@Validated({System.class, Default.class}) @RequestBody MilepostIssueBatchLinkDto param);

    /**
     * issue移除关联的里程碑
     * @param param
     */
    @PostMapping("/api/v1/milepost/batch/unlink_issue")
    void batchRemoveIssueeMilepost(@Validated({System.class, Default.class}) @RequestBody MilepostIssueBatchLinkDto param);

    /**
     * @Desc: 批量获取issue
     * @author: liuzhisheng
     * @date: 2023/10/27 14:14
     */
    @PostMapping("/api/v1/issue/batchGetIssueSimple")
    List<IssueVoDto> batchGetIssueSimple(@RequestBody List<String> issueIds);
}